package com.sz.stock.service;

import com.sz.stock.mapper.BankcardMapper;
import com.sz.stock.model.Bankcard;
import com.sz.stock.model.BankcardExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BankCardServiceImpl implements IBankCardService {

    @Autowired
    private BankcardMapper bankcardMapper ;

    @Autowired
    public void setBankcardMapper(BankcardMapper bankcardMapper) {
        this.bankcardMapper = bankcardMapper;
    }

    @Override
    public int setBankCard(Bankcard bankcard) {
        return bankcardMapper.insertSelective(bankcard);
    }

    /**
     * 通过用户ID 查询指定银行卡信息
     */
    @Override
    public Bankcard selectBankCard(int userid) {
        Bankcard bankcard = new Bankcard();
        BankcardExample example = new BankcardExample();
        BankcardExample.Criteria criteria = example.createCriteria();
        criteria.andBankUseridEqualTo(userid);
        List<Bankcard> bankcards = bankcardMapper.selectByExample(example);
        for (Bankcard bankcard1 : bankcards) {
            bankcard = bankcard1;
        }
        return bankcard;
    }



}
